import request from '@/config/axios'

export interface ModuleVO {
  id: number
  poolName: string
  deptIds: string
  userIds: string
  status: number
  type: number
}

// 查询列表
export const getModulePage = async (params) => {
  return await request.get({ url: `/crm/module/page`, params })
}

// 查询详情
export const getModule = async (id: number) => {
  return await request.get({ url: `/crm/module/get?id=` + id })
}

// 查询simple列表
export const getModuleList = async () => {
  return await request.get({ url: `/crm/module/simple-list` })
}

// 新增
export const createModule = async (data: ModuleVO) => {
  return await request.post({ url: `/crm/module/create`, data })
}

// 修改
export const updateModule = async (data: ModuleVO) => {
  return await request.put({ url: `/crm/module/update`, data })
}

// 删除
export const deleteModule = async (id: number) => {
  return await request.delete({ url: `/crm/module/delete?id=` + id })
}

// 获取拥有客户数限制 锁定客户数限制
export const getModuleCustomerLimit = async (params) => {
  return await request.get({ url: `/crm/module-customer-limit/get`, params })
}

// 获取用户列表
export const getModuleUserList = async (id: number) => {
  return await request.get({ url: `/crm/module/get-user-list?moduleId=` + id })
}

// 新增
export const createModuleCostomerLimit = async (data) => {
  return await request.post({ url: `/crm/module-customer-limit/create`, data })
}

// 获取线索分配规则
export const getClueDistributeConfig = async (id) => {
  return await request.get({ url: `/crm/clue-distribute-config/get?moduleId=` + id })
}
// 保存线索分配规则
export interface ClueVO {
  status: number // 启用状态
  type: number // 分配类型
  limitConfig: number // 领取上限
  defaultOwner: number // 兜底负责人
  moduleId: number // 所属模块
  configList: Array // 配置内容json
}
// 保存线索分配规则
export const saveClueDistributeConfig = async (data: ClueVO) => {
  return await request.post({ url: `/crm/clue-distribute-config/save`, data })
}

// 获取机器人线索分配规则
export const getRobotClueDistributeConfig = async (id) => {
  return await request.get({ url: `/crm/robot-clue-distribute-config/get?moduleId=` + id })
}

// 保存机器人线索分配规则
export const saveRobotClueDistributeConfig = async (data: ClueVO) => {
  return await request.post({ url: `/crm/robot-clue-distribute-config/save`, data })
}

/** 跟进线索类型 */

export interface FollowTypeVO {
  id: number
  name: string
  sort: string
}
// 查询列表
export const getFollowTypeConfigList = async (params) => {
  return await request.get({ url: `/crm/follow-type-config/simple-list`, params })
}
// 查询列表-默认
export const getFollowTypeConfigListDefault = async (params) => {
  return await request.get({ url: `/crm/follow-type-config/simple-list-default`, params })
}
// 查询详情
export const getFollowTypeConfig = async (id: number) => {
  return await request.get({ url: `/crm/follow-type-config/get?id=` + id })
}
// 查询详情默认
export const getFollowTypeConfigDefault = async (id: number) => {
  return await request.get({ url: `/crm/follow-type-config/get-default?id=` + id })
}
// 新增
export const createFollowTypeConfig = async (data: FollowTypeVO) => {
  return await request.post({ url: `/crm/follow-type-config/create`, data })
}
// 新增-默认
export const createFollowTypeConfigDefault = async (data: FollowTypeVO) => {
  return await request.post({ url: `/crm/follow-type-config/create-default`, data })
}
// 修改
export const updateFollowTypeConfig = async (data: FollowTypeVO) => {
  return await request.put({ url: `/crm/follow-type-config/update`, data })
}
export const updateFollowTypeConfigDefault = async (data: FollowTypeVO) => {
  return await request.put({ url: `/crm/follow-type-config/update-default`, data })
}
// 删除
export const deleteFollowTypeConfig = async (id: number) => {
  return await request.delete({ url: `/crm/follow-type-config/delete?id=` + id })
}
// 删除-默认
export const deleteFollowTypeConfigDefault = async (id: number) => {
  return await request.delete({ url: `/crm/follow-type-config/delete-default?id=` + id })
}
// 线索跟进阶段配置
// 查询列表
export const getFollowStageConfigList = async (params) => {
  return await request.get({ url: `/crm/follow-stage-config/simple-list`, params })
}
// 查询列表-默认
export const getFollowStageConfigListDefault = async (params) => {
  return await request.get({ url: `/crm/follow-stage-config/simple-list-default`, params })
}
// 查询详情
export const getFollowStageConfig = async (id: number) => {
  return await request.get({ url: `/crm/follow-stage-config/get?id=` + id })
}
// 查询详情-默认
export const getFollowStageConfigDefault = async (id: number) => {
  return await request.get({ url: `/crm/follow-stage-config/get-default?id=` + id })
}
// 新增
export const createFollowStageConfig = async (data: FollowTypeVO) => {
  return await request.post({ url: `/crm/follow-stage-config/create`, data })
}
// 新增-默认
export const createFollowStageConfigDefault = async (data: FollowTypeVO) => {
  return await request.post({ url: `/crm/follow-stage-config/create-default`, data })
}
// 修改
export const updateFollowStageConfig = async (data: FollowTypeVO) => {
  return await request.put({ url: `/crm/follow-stage-config/update`, data })
}
// 修改-默认
export const updateFollowStageConfigDefault = async (data: FollowTypeVO) => {
  return await request.put({ url: `/crm/follow-stage-config/update-default`, data })
}
// 删除
export const deleteFollowStageConfig = async (id: number) => {
  return await request.delete({ url: `/crm/follow-stage-config/delete?id=` + id })
}
// 删除-默认
export const deleteFollowStageConfigDefault = async (id: number) => {
  return await request.delete({ url: `/crm/follow-stage-config/delete-default?id=` + id })
}
// 号码脱敏配置查询详情
export const getMobileEncrypt = async () => {
  return await request.get({ url: `/crm/mobile-encrypt-config/get` })
}

// 号码脱敏配置保存
export const saveMobileEncrypt = async (data) => {
  return await request.put({ url: `/crm/mobile-encrypt-config/update`, data })
}

// 系统群呼线索查询
export const getClueTransConfig = async (id) => {
  return await request.get({ url: `/crm/clue-trans-config/get?moduleId=${id}` })
}
// 系统群呼线索创建
export const createClueTransConfig = async (data) => {
  return await request.post({ url: `/crm/clue-trans-config/create`, data })
}
// 系统群呼线索编辑
export const updateClueTransConfig = async (data) => {
  return await request.put({ url: `/crm/clue-trans-config/update`, data })
}
// 自定义字段列表
export const customFieldHeadList = async (params) => {
  return await request.get({ url: `/crm/custom-field-head/list`, params })
}
// 自定义字段新增
export const customFieldHeadCreate = async (data) => {
  return await request.post({ url: `/crm/custom-field-head/create`, data })
}
// 自定义字段编辑
export const customFieldHeadUpdate = async (data) => {
  return await request.put({ url: `/crm/custom-field-head/update`, data })
}
// 删除自定义字段
export const customFieldHeadDelete = async (id: number) => {
  return await request.delete({ url: `/crm/custom-field-head/delete?id=` + id })
}
